package com.zzcoder.mall.common.dto;

import com.zzcoder.mall.data.model.OmsOrder;
import com.zzcoder.mall.data.model.OmsOrderItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@ApiModel(value = "销售订单（带明细）")
@Data
public class OmsOrderWithItems extends OmsOrder {
    @ApiModelProperty(value = "销售订单明细列表")
    private List<OmsOrderItem> items = new ArrayList<>();

    public OmsOrderWithItems() {
    }

    public OmsOrderWithItems(OmsOrder order) {
        this.setId(order.getId());
        this.setCreatedTime(order.getCreatedTime());
        this.setCreatorId(order.getCreatorId());
        this.setLastModifiedTime(order.getLastModifiedTime());
        this.setLastModifierId(order.getLastModifierId());
        this.setCode(order.getCode());
        this.setOrderStatus(order.getOrderStatus());
        this.setRemark(order.getRemark());
        this.setMemberId(order.getMemberId());
        this.setMemberNickname(order.getMemberNickname());
        this.setAmount(order.getAmount());
        this.setReceiverName(order.getReceiverName());
        this.setReceiverPhone(order.getReceiverPhone());
        this.setReceiverProvinceCode(order.getReceiverProvinceCode());
        this.setReceiverProvince(order.getReceiverProvince());
        this.setReceiverCityCode(order.getReceiverCityCode());
        this.setReceiverCity(order.getReceiverCity());
        this.setReceiverDistrictCode(order.getReceiverDistrictCode());
        this.setReceiverDistrict(order.getReceiverDistrict());
        this.setReceiverAddress(order.getReceiverAddress());
        this.setOrderTime(order.getOrderTime());
        this.setPaymentTime(order.getPaymentTime());
        this.setPaymentType(order.getPaymentType());
        this.setPaymentAccount(order.getPaymentAccount());
        this.setExpressTime(order.getExpressTime());
        this.setExpressCompany(order.getExpressCompany());
        this.setExpressNumber(order.getExpressNumber());
        this.setReceivedTime(order.getReceivedTime());
        this.setConfirmTime(order.getConfirmTime());
        this.setClosedTime(order.getClosedTime());
    }

    public OmsOrder extractOrder() {
        OmsOrder order = new OmsOrder();
        order.setId(this.getId());
        order.setCode(this.getCode());
        order.setOrderStatus(this.getOrderStatus());
        order.setRemark(this.getRemark());
        order.setMemberId(this.getMemberId());
        order.setMemberNickname(this.getMemberNickname());
        order.setAmount(this.getAmount());
        order.setReceiverName(this.getReceiverName());
        order.setReceiverPhone(this.getReceiverPhone());
        order.setReceiverProvinceCode(this.getReceiverProvinceCode());
        order.setReceiverProvince(this.getReceiverProvince());
        order.setReceiverCityCode(this.getReceiverCityCode());
        order.setReceiverCity(this.getReceiverCity());
        order.setReceiverDistrictCode(this.getReceiverDistrictCode());
        order.setReceiverDistrict(this.getReceiverDistrict());
        order.setReceiverAddress(this.getReceiverAddress());
        order.setOrderTime(this.getOrderTime());
        order.setPaymentTime(this.getPaymentTime());
        order.setPaymentType(this.getPaymentType());
        order.setPaymentAccount(this.getPaymentAccount());
        order.setExpressTime(this.getExpressTime());
        order.setExpressCompany(this.getExpressCompany());
        order.setExpressNumber(this.getExpressNumber());
        order.setReceivedTime(this.getReceivedTime());
        order.setConfirmTime(this.getConfirmTime());
        order.setClosedTime(this.getClosedTime());

        return order;
    }

    public List<OmsOrderItem> extractOrderItems() {
        return this.getItems();
    }
}
